Move notebook to /lib
[andmenj-acm.git] / UVa / 10033 - Interpreter / Eondrej.c
bloba9a584fb9dbd704bb40f60e2e463283ad99d9301
1 int r[12];
2 int m[1200];
4 main() {
5 int i=0;
6 int pc=0;
7 int instr;
8 while( scanf( "%u ", &m[i++] ) == 1 );
9 for(instr=1;;instr++)
10 switch( m[pc]/100 ) {
11 case 1:
12 printf( "%u\n", instr );
13 exit(0);
14 case 2:
15 r[m[pc]/10-20] = m[pc]%10;
16 r[m[pc]/10-20] %= 1000;
17 pc++;
18 break;
19 case 3:
20 r[m[pc]/10-30] += m[pc]%10;
21 r[m[pc]/10-30] %= 1000;
22 pc++;
23 break;
24 case 4:
25 r[m[pc]/10-40] *= m[pc]%10;
26 r[m[pc]/10-40] %= 1000;
27 pc++;
28 break;
29 case 5:
30 r[m[pc]/10-50] = r[m[pc]%10];
31 pc++;
32 break;
33 case 6:
34 r[m[pc]/10-60] += r[m[pc]%10];
35 r[m[pc]/10-60] %= 1000;
36 pc++;
37 break;
38 case 7:
39 r[m[pc]/10-70] *= r[m[pc]%10];
40 r[m[pc]/10-70] %= 1000;
41 pc++;
42 break;
43 case 8:
44 r[m[pc]/10-80] = m[r[m[pc]%10]];
45 pc++;
46 break;
47 case 9:
48 m[r[m[pc]%10]] = r[m[pc]/10-90] ;
49 pc++;
50 break;
51 case 0:
52 if( r[m[pc]%10] ) pc = r[m[pc]/10];
53 else pc++;
54 break;